﻿using MediatR;
using Traceability.App.Applications.Command.Aquaculture;
using Traceability.Domain.Entity;
using Traceability.Domain.Repository;
using Traceability.Enum;

namespace Traceability.App.Applications.CommandHand.Aquaculture
{
    public class GetshowCommandHandler : IRequestHandler<GetshowCommand, ApiResult<AquacultureModel>>
    {

        private readonly IBaseRepository<AquacultureModel> _aquaculture;

        public GetshowCommandHandler(IBaseRepository<AquacultureModel> aquaculture)
        {
            _aquaculture = aquaculture;
        }

        public Task<ApiResult<AquacultureModel>> Handle(GetshowCommand request, CancellationToken cancellationToken)
        {
           var resule=new ApiResult<AquacultureModel>();
            var Aquaculture = _aquaculture.GetAll().FirstOrDefault(x => x.Batch == request.Batch);
            if (Aquaculture != null)
            {

                resule.data = Aquaculture;
             
            }


            return Task.FromResult(resule);


        }
    }
}
